

	<!-- 可变效果区 -->
	<div class="main ">

		<div class="row">
			<div class="col-lg-12">
				<h3 class="page-header"><i class="fa fa-indent"></i>角色添加</h3>

			</div>
		</div>

		<div class="row">
		    <div class="col-md-10">
		        <div class="panel panel-default">
		            <div class="panel-heading">
		                <h2><i class="fa fa-indent red"></i><strong>添加</strong></h2>
		            </div>
					<div class="panel-body">
						<form action="index.php?c=role&a=add&admin=1" method="post" enctype="multipart/form-data" class="form-horizontal ">

			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="text-input">角色名称</label>
			                    <div class="col-md-8">
			                        <input type="text" id="text-input" name="name" class="form-control" placeholder="请输入用户名">

			                    </div>
			                </div>

			                <div class="form-group">
			                    <label class="col-md-2 control-label" for="text-input">是否启用</label>
			                    <div class="col-md-9" style="line-height: 30px;">
			                        <input type="radio" id="text-input" name="status" value="1">是
			                        <input type="radio" id="text-input" name="status" value="0">否

			                    </div>
			                </div>
			                <div class="col-md-8" style="margin-left: 220px;">
								<div class="panel panel-default">
									<div class="panel-heading">
										<h2><i class="fa fa-list red"></i><span class="break"></span><strong>权限</strong></h2>
                                        <button class="btn btn-default allcheck" type="button" style="margin-left: 20px;">全选</button>
                                        <button class="btn btn-default allnot" type="button">取消</button>
									</div>

									<div class="panel-body">
									    <?php foreach($parent as $v){ ?>
										<div id="accordion" class="panel-group">
										  <div class="panel panel-default">
										    <div class="panel-heading">
										      <h4 class="panel-title">
										          <input type="checkbox" name="power[]"  value="<?=$v['id'];?>"><?=$v['name'];?>
										      </h4>
										    </div>
										    <div class="panel-body" style="padding-left: 30px;">
								            <?php foreach($child as $v1){ ?>
								                <?php if($v['id']==$v1['pid']){?>
											        <input type="checkbox" name="power[]" value="<?=$v1['id'];?>"><?=$v1['name'];?>
										        <?php }?>
									        <?php }?>
										    </div>
										  </div>
										</div>
									    <?php }?>
									</div>
								</div>
							</div>

					</div>
					<div class="panel-footer" style="text-align: center;">
	                    <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i>提交</button>
                        <button type="reset" class="btn btn-sm btn-danger"><i class="fa fa-ban"></i>重置</button>
	                </div>
	                </form>
		        </div>
		    </div>


		</div><!--/.row-->

	</div>
	<!-- end: Content -->
	<br><br><br>


	<script src="resources/admin/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript">
		$(function(){
			//顶级全选
			$('.panel-title :checkbox').click(function(){

				if($(this).is(':checked')){
					$(this).parent().parent().next().find(':checkbox').prop('checked',true);
				}else{
				    $(this).parent().parent().next().find(':checkbox').prop('checked',false);
				}

			})
            //子级勾父级
			$('.panel-body :checkbox').click(function(){

				var len = $(this).parent().find(':checkbox:checked').length;

				if(len>0){
					$(this).parent().prev().find(':checkbox').prop('checked',true);
				}else{
					$(this).parent().prev().find(':checkbox').prop('checked',false);

				}
			})

			// 全选
		    $('.allcheck').click(function(){
		    	$(this).parent().parent().find(':checkbox').prop('checked',true);

		    })

		    // 取消全选
		    $('.allnot').click(function(){
		    	$(this).parent().parent().find(':checkbox').prop('checked',false);
		    })

		})
	</script>